package com.deyuanyun.pic.ae.controller.vo;

import com.deyuanyun.pic.ae.domain.GeologicHazard;
import com.deyuanyun.pic.ae.enumeration.RiskLevelEnum;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.util.PipeMgrUtil;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * “管道沿线地质灾害信息” 查询展示对象
 *
 * 方法详情：<br/>
 *
 * @author huanglw
 * @date  2016-11-9
 *
 * History: [修改人][时间][修改描述]
 */
public class GeologicHazardVO extends AEBaseVO<GeologicHazard> {

    // 管道名称
    private String pipeLineName;
    // 类型（粘土滑坡、碎石土滑坡、黄土滑坡、岩体滑坡、崩塌、泥石流、采空区塌陷、坡面水毁、河沟道水毁、台田地水毁、黄土湿陷、盐渍土、冻土、岩溶塌陷、地面沉降、地裂缝、地震液化、水化学腐蚀、人类工程活动）
    private String type;
    // 风险概率分值
    private String riskProbabilityScore;
    // 风险概率分级
    private String riskProbabilityLevel;
    // (填写)平行起点_附近测试桩pic_pipe_identification.ID_
    private String beginNagmInput;
    // (填写)平行起点_附近测试桩距离（相对值）
    private BigDecimal beginNagmMileageInput;
    // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
    private String endNagmInput;
    // (填写)平行段终点_附近测试桩距离（相对值）
    private BigDecimal endNagmMileageInput;
    // 位置描述
    private String locationDescription;
    // 后果分级
    private String consequenceLevel;
    // 风险等级（高、中高、中、中低、低、未知）
    private String riskLevel;

    // 数据状态
    private String dataStated;
    private String gisid;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getRiskProbabilityScore() {
        return riskProbabilityScore;
    }

    public void setRiskProbabilityScore(String riskProbabilityScore) {
        this.riskProbabilityScore = riskProbabilityScore;
    }

    public String getRiskProbabilityLevel() {
        return riskProbabilityLevel;
    }

    public void setRiskProbabilityLevel(String riskProbabilityLevel) {
        this.riskProbabilityLevel = riskProbabilityLevel;
    }

    public String getBeginNagmInput() {
        return beginNagmInput;
    }

    public void setBeginNagmInput(String beginNagmInput) {
        this.beginNagmInput = beginNagmInput;
    }

    public BigDecimal getBeginNagmMileageInput() {
        return beginNagmMileageInput;
    }

    public void setBeginNagmMileageInput(BigDecimal beginNagmMileageInput) {
        this.beginNagmMileageInput = beginNagmMileageInput;
    }

    public String getEndNagmInput() {
        return endNagmInput;
    }

    public void setEndNagmInput(String endNagmInput) {
        this.endNagmInput = endNagmInput;
    }

    public BigDecimal getEndNagmMileageInput() {
        return endNagmMileageInput;
    }

    public void setEndNagmMileageInput(BigDecimal endNagmMileageInput) {
        this.endNagmMileageInput = endNagmMileageInput;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getConsequenceLevel() {
        return consequenceLevel;
    }

    public void setConsequenceLevel(String consequenceLevel) {
        this.consequenceLevel = consequenceLevel;
    }

    public String getRiskLevel() {
        return riskLevel;
    }

    public void setRiskLevel(String riskLevel) {
        this.riskLevel = riskLevel;
    }

    public String getDataStated() {
        return dataStated;
    }

    public void setDataStated(String dataStated) {
        this.dataStated = dataStated;
    }

    public String getGisid() {
        return gisid;
    }

    public void setGisid(String gisid) {
        this.gisid = gisid;
    }

    @Override
    public void fromDomain(GeologicHazard domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 类型（粘土滑坡、碎石土滑坡、黄土滑坡、岩体滑坡、崩塌、泥石流、采空区塌陷、坡面水毁、河沟道水毁、台田地水毁、黄土湿陷、盐渍土、冻土、岩溶塌陷、地面沉降、地裂缝、地震液化、水化学腐蚀、人类工程活动）
        this.type = CodeUtil.getName(domain.getType());
        // 风险概率分值
        this.riskProbabilityScore = domain.getRiskProbabilityScore();
        // 风险概率分级
        this.riskProbabilityLevel = domain.getRiskProbabilityLevel();
        // 平行起点_附近测试桩pic_pipe_identification.ID_
//        this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmInput()) ? PipeMgrUtil.getIdentificationNumber(domain.getBeginNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getBeginNagm());
        this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmNumberInput() : domain.getBeginNagmNumber();
        // 平行起点_附近测试桩距离（相对值）
        Long beginNagmMileageTemp = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmMileageInput() : domain.getBeginNagmMileage();
        this.beginNagmMileageInput = NumberUtil.toMeter(beginNagmMileageTemp);
        // 平行段终点_附近测试桩pic_pipe_identification.ID_
//        this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmInput()) ? PipeMgrUtil.getIdentificationNumber(domain.getEndNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getEndNagm());
        this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmNumberInput() : domain.getEndNagmNumber();
        // 平行段终点_附近测试桩距离（相对值）
        Long endNagmMileageTemp = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmMileageInput() : domain.getEndNagmMileage();
        this.endNagmMileageInput = NumberUtil.toMeter(endNagmMileageTemp);
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 后果分级
        this.consequenceLevel = domain.getConsequenceLevel();
        // 风险等级（高、中高、中、中低、低、未知）
        this.riskLevel = RiskLevelEnum.getLabel(domain.getRiskLevel());

        // 数据状态
        this.dataStated = domain.getDataStated();
        this.gisid = domain.getGisid();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<GeologicHazardVO> fromDomainList(Page<GeologicHazard> domainList) {
        Page<GeologicHazardVO> list = new Page<GeologicHazardVO>();
        for (GeologicHazard geologicHazard : domainList) {
            GeologicHazardVO geologicHazardVO = new GeologicHazardVO();
            geologicHazardVO.fromDomain(geologicHazard);
            list.add(geologicHazardVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}